package com.limanyik.family.kernel.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.limanyik.family.common.utils.FamilyHttpResponse;
import com.limanyik.family.kernel.communication.dto.FamilyBucketInfoDto;
import com.limanyik.family.kernel.communication.vo.FamilyBucketInfoVo;
import com.limanyik.family.kernel.entity.FamilyBucketInfo;
import com.limanyik.family.kernel.mapper.FamilyBucketInfoMapper;
import com.limanyik.family.kernel.service.FamilyBucketInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 家庭桶信息表 服务实现类
 *
 * @author limanyi
 * @since 2022-01-24
 */
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class FamilyBucketInfoServiceImpl implements FamilyBucketInfoService {

    @Resource(name = "familyBucketInfoMapper")
    FamilyBucketInfoMapper familyBucketInfoMapper;


    @Override
    public FamilyHttpResponse<List<FamilyBucketInfoVo>> getFamilyBucketInfoByUserId(FamilyBucketInfoDto familyBucketInfoDto) {
        return FamilyHttpResponse.success(familyBucketInfoMapper.getFamilyBucketInfoByUserId(familyBucketInfoDto));
    }

    @Override
    public FamilyHttpResponse<IPage<FamilyBucketInfoVo>> getFamilyBucketInfoPageByUserId(FamilyBucketInfoDto familyBucketInfoDto) {
        return FamilyHttpResponse.success(familyBucketInfoMapper.getFamilyBucketInfoByUserId(new Page<>(familyBucketInfoDto.getPage(), familyBucketInfoDto.getPageSize()), familyBucketInfoDto));
    }
}
